<?php
/**
 * Created by PhpStorm.
 * User: yfl
 * Date: 2021/1/20
 * Time: 0:06
 */

namespace app\printer\controller;


//记录
use think\Db;
use think\facade\Request;

class RecodeController extends BaseController
{
    //创建打印机库存记录
    public function createInventoryRecode($data,$type = 0)
    {
       $inventory_recode_table = Db::name('inventory_recode')->insertAll($data);
       if($inventory_recode_table) return true;
       return false;
    }
    //得到打印机库存记录
    public function getInventoryRecode()
    {
        $page = Request::get('page', 0);
        $limit = Request::get('limit', 15);
        $lists = Db::name('inventory_recode')->page($page, $limit)->order(['id'=>'desc','create_time'=>'desc'])->select();
        $count = Db::name('inventory_recode')->count();
        return ['data' => $lists, 'count' =>$count,'code' => 0];
    }
    //删除打印机库存记录
    public function delInventoryRecode()
    {
        $id  = Request::param('id');
        $res = Db::name('inventory_recode')->delete($id);
        if($res){
            return $this->ajaxSuccess();
        }else{
            return $this->ajaxFail();
        }
    }
}